package main.java.com.uc.training.smadmin.gds.dao.impl;

import com.uc.training.smadmin.gds.dao.CommentDao;
import com.uc.training.smadmin.gds.model.Comment;
import com.uc.training.smadmin.gds.re.CommentRE;
import com.uc.training.smadmin.gds.vo.CommentAvgVO;
import com.uc.training.smadmin.gds.vo.CommentListVO;
import com.uc.training.smadmin.gds.vo.CommentPicVO;
import com.uc.training.smadmin.gds.vo.CommentVO;
import com.zuche.framework.dao.CarIsIbatisDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 版权声明： Copyright (c) 2008 ucarinc. All Rights Reserved.
 *
 * @author 何麒（qi.he@ucarinc.com）
 * @Version 1.0
 * @date 2018/11/17
 */
@Repository
public class CommentDaoImpl extends CarIsIbatisDaoImpl implements CommentDao {
  private static final String namespace = "com.uc.training.smadmin.gds.dao.CommentDao.";

    @Override
    public Integer addCommentPic(CommentPicVO commentPicVO) {
        return (Integer) this.insert(namespace + "addCommentPics", commentPicVO);
    }

    @Override
    public Long addComment(CommentVO commentVO) {
        return (Long) this.insert(namespace + "addComment", commentVO);
    }

    @Override
    public List<Comment> getCommentCountByOrdergoodsId(Long orderGoodsId) {
        return this.queryForList(namespace + "getCommentCountByOrdergoodsId", orderGoodsId);
    }

  /**
   * 获取评论
   *
   * @param commentListVO
   * @return
   */
  @Override
  public List<CommentRE> getCommentList(CommentListVO commentListVO) {
    return this.queryForList(namespace + "getCommentList", commentListVO);
  }

  @Override
  public Integer getCountBySroce(CommentListVO commentListVO) {
    return (Integer)this.queryForObject(namespace+"getCountBySroce",commentListVO);
  }

  @Override
  public CommentAvgVO getCommentCountAndAvg(CommentListVO commentListVO) {
    return (CommentAvgVO)this.queryForObject(namespace+"getCommentCountAndAvg",commentListVO);
  }

  @Override
  public Integer editCommentById(CommentVO commentVO) {
    return (Integer)this.update(namespace+"editCommentById",commentVO);
  }

  @Override
  public Integer delCommentById(Long commentId) {
    return (Integer)this.deleteObject(namespace+"delCommentById",commentId);
  }
}
